<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<form action="" method="post">
			<input type="text" required="required" />
			<input type="password" name="pwd1" id="pwd1" required="required" />
			<input type="password" name="pwd2" id="pwd2" required="required" />
			  <input type="text" name="country_code" id="reg" pattern="[A-z]{3}" required="required" title="Three letter country code" />
			<input type="button" onclick="Valid()" value="提交"/>
		</form>
		<script src="js/jquery.min.js"></script>		
		<script type="text/javascript">
			function Valid(){
				var form = document.querySelector('form')
				var pass1 = document.getElementById("pwd1");
				var pass2 = document.getElementById("pwd2");
				if(pass1.value !=pass2.value){
//					pass2.setCustomValidity("两次输入的密码不一致");
				}					
				else{
//					pass2.setCustomValidity("");
				}		
				console.log(document.getElementById('reg').checkValidity())
				//检测表单合法性		
				console.log(pass2.checkValidity())
				console.log(form.checkValidity())
			}
		</script>
	</body>
</html>
